package api

import (
	"github.com/emicklei/go-restful"
	"github.com/jinzhu/gorm"

	"github.com/xdhuxc/asset-management-system/src/service"
)

type BaseController struct {
	db *gorm.DB
	bs *service.BaseService
	ws *restful.WebService
}

func NewBaseController(db *gorm.DB) *BaseController {
	ws := new(restful.WebService)

	ws.Path("/ams/api/v1").
		Consumes(restful.MIME_JSON, restful.MIME_XML).
		Produces(restful.MIME_JSON, restful.MIME_XML)

	baseController := &BaseController{
		ws: ws,
		db: db,
		bs: service.NewBaseService(db),
	}

	newHealthCheckController(baseController)
	newDictionaryController(baseController)
	newUserController(baseController)
	newTransactionController(baseController)

	return baseController
}
